<template>
  <div class="student">
    <h2>学生姓名：{{name}}</h2>
    <h2>学生性别：{{sex}}</h2>
    <button @click="sendStudentName">点我发送学生姓名</button>
  </div>
</template>

<script>
  import pubsub from "pubsub-js";

  export default {
    name: "Student",
    data() {
      return {
        name: "张三",
        sex: "男"
      }
    },
    mounted() {
      // console.log(window.x);
      // console.log('Student', this.$bus);
    },
    methods: {
      sendStudentName() {
        // this.$bus.$emit('hello', this.name)
        pubsub.publish('hello', 6666)
      }
    }
  };
</script>

<style lang="less">
  .student {
    background-color: orange;
    margin-top: 30px;
    padding: 5px;
  }
</style>